package com.ysd.twocrm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysd.twocrm.entity.Dynamic;
import com.ysd.twocrm.mapper.DynamicMapper;
import com.ysd.twocrm.service.DynamicService;
import com.ysd.twocrm.utils.LayuiUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DynamicServiceImpl implements DynamicService {
@Autowired
     private DynamicMapper dynamicMapper;
    @Override
    public LayuiUtils<Dynamic> DYNAMIC_LAYUI_UTILS(Dynamic d, Integer page) {

        Page<Dynamic> dynamicPage=new Page<Dynamic>(page,10);
        QueryWrapper<Dynamic> dynamicQueryWrapper=new QueryWrapper<>();
        dynamicQueryWrapper.eq("dIsopen",d.getdIsopen()).eq("userId",d.getUserId()).orderByDesc("did");
        Page<Dynamic> dynamicPage1 = dynamicMapper.selectPage(dynamicPage, dynamicQueryWrapper);
        LayuiUtils<Dynamic> dynamicLayuiUtils=new LayuiUtils<>();
        dynamicLayuiUtils.setCount(dynamicPage1.getTotal());
        dynamicLayuiUtils.setData(dynamicPage1.getRecords());
        return dynamicLayuiUtils;
    }
}
